const path = require("path");
const getBaseCfg = require("./webpack.base");
const { merge } = require("webpack-merge");
const CssMiniMizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugins = require("terser-webpack-plugin");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = merge(getBaseCfg(getBaseCfg), {
  mode: "production",
  optimization: {
    minimize: true,
    minimizer: [
      new CssMiniMizerPlugin(),
      new TerserPlugins({
        parallel: true,
      }),
    ],
    splitChunks: {
      cacheGroups: {
        vendors: {
          name: "vendors",
          test: /node_modules/,
        },
        common: {
          name: "common",
        },
      },
      // chunks: 'async',
      // minSize: 20000,
      // minRemainingSize: 0,
      // minChunks: 1,
      // maxAsyncRequests: 30,
      // maxInitialRequests: 30,
      // enforceSizeThreshold: 50000,
    },
  },
  plugins: [new BundleAnalyzerPlugin()],
});
